/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

#gameContainer {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 20px;
    max-width: 500px;
    width: 100%;
    backdrop-filter: blur(10px);
}

/* 游戏标题 */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 2.5em;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-display {
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
    font-weight: bold;
    color: #2d3748;
}

/* 游戏主界面 */
.game-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* 画布容器 */
.canvas-container {
    position: relative;
    border: 3px solid #4a5568;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.1),
        0 0 30px rgba(102, 126, 234, 0.3),
        0 0 60px rgba(118, 75, 162, 0.2);
    transition: box-shadow 0.3s ease;
}

.canvas-container:hover {
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.1),
        0 0 40px rgba(102, 126, 234, 0.5),
        0 0 80px rgba(118, 75, 162, 0.3);
}

/* 合成时的特殊发光效果 */
.canvas-container.merge-glow {
    animation: mergeGlow 0.6s ease-out;
}

@keyframes mergeGlow {
    0% {
        box-shadow: 
            inset 0 0 20px rgba(0, 0, 0, 0.1),
            0 0 30px rgba(102, 126, 234, 0.3),
            0 0 60px rgba(118, 75, 162, 0.2);
    }
    50% {
        box-shadow: 
            inset 0 0 20px rgba(0, 0, 0, 0.1),
            0 0 60px rgba(255, 215, 0, 0.8),
            0 0 120px rgba(255, 105, 180, 0.6),
            0 0 180px rgba(138, 43, 226, 0.4);
    }
    100% {
        box-shadow: 
            inset 0 0 20px rgba(0, 0, 0, 0.1),
            0 0 30px rgba(102, 126, 234, 0.3),
            0 0 60px rgba(118, 75, 162, 0.2);
    }
}

#gameCanvas {
    display: block;
    background: linear-gradient(to bottom, #e6f3ff 0%, #cce7ff 100%);
    width: 400px;
    height: 600px;
    max-width: 100%;
    max-height: 70vh;
    filter: contrast(1.1) saturate(1.1);
    transition: filter 0.3s ease;
}

#gameCanvas:hover {
    filter: contrast(1.15) saturate(1.15) brightness(1.05);
}

/* 屏幕震动效果 */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-2px, -1px) rotate(-0.5deg); }
    20% { transform: translate(2px, 1px) rotate(0.5deg); }
    30% { transform: translate(-1px, 2px) rotate(-0.3deg); }
    40% { transform: translate(1px, -2px) rotate(0.3deg); }
    50% { transform: translate(-2px, 1px) rotate(-0.2deg); }
    60% { transform: translate(2px, -1px) rotate(0.2deg); }
    70% { transform: translate(-1px, -2px) rotate(-0.1deg); }
    80% { transform: translate(1px, 2px) rotate(0.1deg); }
    90% { transform: translate(-1px, 1px) rotate(-0.05deg); }
}

/* 游戏遮罩层 */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.overlay-content p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* 按钮样式 */
.game-button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.game-button:active {
    transform: translateY(0);
}

/* 控制面板 */
.control-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.next-ball {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.ball-preview {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ff6b6b;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.game-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: right;
    font-size: 0.9em;
}

/* 道具栏 */
.power-ups {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.power-up-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2em;
    position: relative;
    min-width: 60px;
}

.power-up-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.power-up-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.power-up-btn .count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7em;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 设置菜单 */
.settings-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.settings-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    min-width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.settings-content h3 {
    margin-bottom: 20px;
    color: #4a5568;
    text-align: center;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.setting-item label {
    font-weight: bold;
    color: #666;
}

.setting-item input[type="checkbox"] {
    transform: scale(1.2);
}

.setting-item select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

/* 底部按钮 */
.game-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.footer-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.footer-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

/* 工具类 */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}

/* 球体颜色定义 */
.ball-level-1 { background: #ff6b6b; }
.ball-level-2 { background: #ffa726; }
.ball-level-3 { background: #ffeb3b; }
.ball-level-4 { background: #66bb6a; }
.ball-level-5 { background: #26c6da; }
.ball-level-6 { background: #42a5f5; }
.ball-level-7 { background: #ab47bc; }
.ball-level-8 { background: #ec407a; }
.ball-level-9 { 
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* 粒子效果 */
.particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translateY(-50px);
    }
}